<div class="sk_bt">
	<p>
		<i>
		</i>
	</p>
</div>
<table width="100%" data-id="table1" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<i title="添加过滤器" style="display: none;" href="" id="filteradd_id" data-toggle="load" data-target="#filterlist_div"></i>
			<div id="filter_div" onmouseover="targetId=this.id" onmouseout="targetId=''" class="nr">
				<#if filters?? && filters?size gt 0>
				
				<#list filters as filter> 										
				<#if filter.funtype?? && filter.funtype=="filter" && filter.request == false>
				<div id="filter_menu_${filter.id!''}" class="menuContent" style="display:none; position: absolute;border: 1px solid #09f;width:313px;overflow:auto;;background-color:#FFFFFF;height:180px;z-index:10000;">
					<ul id="tree_${filter.id!''}" class="ztree"></ul>
				</div>
				</#if>
				</#list> 
				
				<script type="text/javascript">
					var filterSetting = {
						view: {
							dblClickExpand: false ,
							nameIsHTML: true ,
							showIcon : false
						},
						data: {
							simpleData: {
								enable: true
							}
						},
						callback: {
							onClick: onClick
						}
					};
					function onClick(e, treeId, treeNode) {	   						
						e.stopPropagation();//点击Button阻止事件冒泡到document
						notification("",false);
					}
					$(document).ready(function(){
						$('input').on("click",function(e){
							if($(this).attr('data-id')){
								if (e && e.stopPropagation) {//非IE  
									 e.stopPropagation();  
								 }else {//IE  
									 window.event.cancelBubble = true;  
								 }	   
								 showFilterMenu($(this).attr('data-id'));
								 return false ;
							 }
						});
						$('input[type="text"]').on("change",function(e){
							if($("#rivuDatePannel").length==0||$("#rivuDatePannel").css("display")=="none"){
								saveFilterValues();
							}
						});
						
					 });
					function showFilterMenu(id) {
						var cityOffset = $('#input_'+id).position();
						$("#filter_menu_"+id).css({left:cityOffset.left+"px", top:(cityOffset.top+23)+"px"}).css("width",$('#input_'+id).width()+30).show();
						$("body").unbind("click", onBodyDownFilter);
						$("body").bind("click", onBodyDownFilter);
					}
					function hideFilterMenu() {
						$(".menuContent").hide();
						$("body").unbind("click", onBodyDownFilter);
					}
					function onBodyDownFilter(event) {
						if($(event.target).parents('.menuContent').length > 0 ){
						
						}else{
							hideFilterMenu();
						}
					}
					function addCheckFilter(box){
						var url = "/${orgi}/design/query/filterdrag/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>.html" ;
						url = url+"?id="+ $(box).attr('data-filter')+"&type="+$(box).attr('data-type')+"&name="+encodeURIComponent($(box).attr('data-name'))+"&selected="+$(box).prop('checked')+"&filter="+encodeURIComponent($(box).attr('data-level'));
						loadURL(url,'#filter_select_'+$(box).attr('data-filter'),function(){
							resizeDesign();
						})
					}
					function loadCascadeFilterValue(obj){
						var cascadeid = $(obj).attr("cascadeid");
						if(cascadeid!=undefined&&cascadeid!=""){
							loadURL("/${orgi}/design/query/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>/"+cascadeid+"/loadfiltervalues.html?parentid="+$(obj).attr("id").replace('filter_select_','')+"&parentvalue="+encodeURIComponent($(obj).val()),"#filter_select_"+cascadeid,null);
						}else{
							saveFilterValues();
						}
						
					}
					
					function saveFilterValues(){	
						var formValue = $("#filterlist_form") ;
						notification("请稍候，正在加载······",true,false);	//开始
						if(formValue.valid()){
							formValue.ajaxSubmit({	  
								url:url_list.savefiltervalues_url+"?ps="+$("#ps").val(),
								success: function(data){
									notification("",false);	//结束
									if(closeDialog && currentArtDialog!=null){
										currentArtDialog.close();
									}
								},
								error:function(xhr, type, s){  				
									notification("",false);	//结束
								}
							}); 
						}else{
							notification("",false);	//结束
						}	
					}
					
					$("#filter_div").scroll(function() {
						$("#filterlist_form").valid();
					});
				</script>
				<span class="nrspan">
					<#assign auth = false />
					<#list filters as filter> 	
						
					<#if cube??>
						<#list cube.dimension as dim>
							<#if dim.cubeLevel??>
								<#list dim.cubeLevel as level>
									<#if level??&&filter.dataid??&&level.id==filter.dataid>
										<#assign auth = true />
									</#if>
								</#list>
							</#if>
							<#if dim.dim?? && dim.dim.cubeLevel??>
								<#list dim.dim.cubeLevel as level>
									<#if level??&&filter.dataid??&&level.id==filter.dataid>
										<#assign auth = true />
									</#if>
								</#list>
							</#if>
						</#list>
					<#else>
						<#break>
					</#if>			
												
					<#if auth&&filter.funtype?? && filter.funtype=="filter">
					<div class="<#if filter.valuefiltertype?? && filter.valuefiltertype == 'range'>f_slc_range<#else>f_slc</#if>" style="border:1px solid #d9d9d9;">
						<div class="filter_input filter_icon">
							<span class="filter_label nrspan" style="padding-top:2px;padding-right:3px;">
								<div class="filter_label_a" style="padding-top:2px;padding-right:3px;">
									<a href="/${orgi}/design/query/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>/editFilter/${filter.id!''}.html" data-toggle="ajax" title="修改过滤器">
										<#if filter.name??>${filter.name!''}<#else>${filter.dataname!''}</#if>				
										<#if filter.comparetype?? && filter.comparetype="not">
											（不等于）
										</#if>
									</a>
								</div>
								<div class="filter_label_rm" style="padding-top:2px;padding-right:3px;"> 
									<a href="/${orgi}/design/query/filterdelo/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>/${filter.id!''}.html" data-toggle="load" data-target="#filterlist_div" style="margin-left:5px;"><img src="/assets/images/deletered.png" height="8" width="8"></a>
								</div>
							</span>

							<#assign inlineTemplate = filter.curvalue?interpret>
							<#if filter.modeltype?? && filter.modeltype == "text" >
								

								<#if filter.valuefiltertype?? && filter.valuefiltertype == 'range'>
								<input type="text" class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name="${filter.code!''}_start" id="${filter.code!''}_start" value="<#if filter.requeststartvalue??>${filter.requeststartvalue}<#else><@inlineTemplate /></#if>" style="padding-left:3px;height:21px;border:1px solid #09f;width:100px">

								<span class="filter_label_sp" style="padding-top:2px;padding-right:3px;">
								~	
								</span>
								<input type="text" class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name="${filter.code!''}_end" id="${filter.code!''}_end" value="<#if filter.requestendvalue??>${filter.requestendvalue}<#else><@inlineTemplate /></#if>" style="padding-left:3px;height:21px;border:1px solid #09f;width:100px">

								<#else>
								<input type="text" class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name="${filter.code!''}" id="${filter.code!''}" value="<#if RequestParameters[filter.id]??>${RequestParameters[filter.id]}<#elseif filter.requestvalue??>${filter.requestvalue}<#else><@inlineTemplate /></#if>" style="padding-left:3px;height:21px;border:1px solid #09f;width:100px">
								</#if>
							
							<#elseif filter.modeltype?? && filter.modeltype == "date" >

								<#if filter.valuefiltertype?? && filter.valuefiltertype == 'range' && filter.curstartvalue??>
								<#assign startInlineTemplate = filter.curstartvalue?interpret>
								<input class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" type="text" readOnly="true" name="${filter.code!''}_start" id="${filter.code!''}_start" style="padding-left:3px;border: 1px solid #09f;width:100px" value="<#if filter.requeststartvalue??>${filter.requeststartvalue}<#else><@startInlineTemplate /></#if>" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'${filter.code!''}_end\')}',dateFmt:'${filter.formatstr!'yyyy-MM-dd'}'})">
								<span class="filter_label_sp" style="padding-top:2px;padding-right:3px;">
								~
								</span>
								<#assign endInlineTemplate = filter.curendvalue?interpret>
								<input type="text" class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" readOnly="true" name="${filter.code!''}_end" id="${filter.code!''}_end" style="padding-left:3px;border: 1px solid #09f;width:100px" value="<#if filter.requestendvalue??>${filter.requestendvalue}<#else><@endInlineTemplate /></#if>" onClick="WdatePicker({minDate:'#F{$dp.$D(\'${filter.code!''}_start\')}',dateFmt:'${filter.formatstr!'yyyy-MM-dd'}'})">
								<#else>
								<#assign defaultValueTemplate = filter.curvalue?interpret>
								<input type="text" class="slcvalue <#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" readOnly="true" name="${filter.code!''}" id="${filter.code!''}" style="padding-left:3px;border: 1px solid #09f;width:100px" value="<@defaultValueTemplate/>" onClick="WdatePicker({dateFmt:'${filter.formatstr!'yyyy-MM-dd'}'})">
								</#if>
							<#elseif filter.modeltype?? && filter.modeltype == "sigsel" >
								<#if filter.valuefiltertype?? && filter.valuefiltertype == 'range'>	   <!-- 日期 范围查询  -->
								<select onchange="loadCascadeFilterValue(this)" class="<#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name='${filter.code!""}_start' id='${filter.code!""}_start' style="padding: 0 0 0 3px;border: 1px solid #09f;width:auto;height:22px;">
									<option value="">请选择<#if filter_auto_size??>(${filter_auto_size!''}条上限)<#else>...</#if></option>
									<#if filter.reportData?? && filter.reportData.row?? && filter.reportData.row.title??>
										<#list filter.reportData.row.title as titles>
										<#list titles as title>
										<#if title.name??&&title.name?trim!=''>
										<option value="<#if title.getCubeLevel(filter.dataname!'')!=''>${title.getCubeLevel(filter.dataname!'')!''}<#else>${title.name!''}</#if>" <#if filter.requeststartvalue??&&filter.requeststartvalue!='' && (filter.requeststartvalue == title.name || filter.requeststartvalue == title.getCubeLevel(filter.dataname!''))>selected="selected"</#if>><#if title.getCubeLevel(filter.dataname!'')!=''>${title.getCubeLevel(filter.dataname!'')!''}<#else>${title.name!''}</#if></option>
										</#if>
										</#list>
									</#list>									
									</#if>
								</select>

								<span class="filter_label_sp" style="padding-top:2px;padding-right:3px;">
								~
								</span>


								<select onchange="loadCascadeFilterValue(this)" class="<#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name='${filter.code!""}_end' id='${filter.code!""}_end' style="padding: 0 0 0 3px;border: 1px solid #09f;width:auto;height:22px;">
									<option value="">请选择<#if filter_auto_size??>(${filter_auto_size!''}条上限)<#else>...</#if></option>
									<#if filter.reportData?? && filter.reportData.row?? && filter.reportData.row.title??>
										<#list filter.reportData.row.title as titles>
										<#list titles as title>
										<#if title.name??&&title.name?trim!=''>
										<option value="<#if title.getCubeLevel(filter.dataname!'')!=''>${title.getCubeLevel(filter.dataname!'')!''}<#else>${title.name!''}</#if>" <#if filter.requestendvalue??&&filter.requestendvalue!='' && (filter.requestendvalue == title.name || filter.requestendvalue == title.getCubeLevel(filter.dataname!''))>selected="selected"</#if>><#if title.getCubeLevel(filter.dataname!'')!=''>${title.getCubeLevel(filter.dataname!'')!''}<#else>${title.name!''}</#if></option>
										</#if>
										</#list>
									</#list>									
									</#if>
								</select>


								<#else>	 <!-- 日期 比较查询  -->
								<select onchange="loadCascadeFilterValue(this)" cascadeid="${filter.cascadeid!''}" id="filter_select_${filter.id!''}" class="<#if filter.mustvalue?? && filter.mustvalue=='mustvalue'>required</#if>" name='${filter.code!""}' style="padding: 0 0 0 3px;border: 1px solid #09f;width:auto;height:22px;">
									<#include "loadfiltervalues.html"/>
								</select>
								</#if>
							<#elseif filter.modeltype?? && filter.modeltype == "select" >
							<span class="input_wrap nrspan" id="filter_select_${filter.id!''}" style="padding:0px;">
								<#include "loadfiltervalues.html"/>
							</span>
							</#if>
						</div> 		
					</div>
					</#if>
					</#list> 	
				</span>
				<#else>
				<p>过滤器列表:</p>
				<span>
					<img src="/assets/images/right_icon1.png">
				</span>
				拖拽维度的成员或者指标到此创建一个过滤器
				</#if>
			</div>
		</td>
		<td style="width:70px;">
			<div class="bottomBg">
				<div class="btnWrap" style="margin-top:0px;text-align:right;width:100%;">
					<a href="javascript:void(0)" onclick="art.confirm('您确定要删除所有过滤器吗？' , function(){$('#clear_filter_i').click()} , function(){})" title="清空过滤器（删除所有过滤器）" style="padding-right:7px;float:right;"><img src="/assets/images/removefilter.png"/></a>
					<a href="javascript:void(0)" onclick="art.confirm('您确定要重置所有过滤器的值吗？' , function(){$('#reset_filter_i').click()} , function(){})" title="重置过滤器（删除过滤器的值）" style="padding-right:7px;float:right;padding-right:0px;"><img src="/assets/images/archive-extract-2.png"/></a>
					<i style="display: none;" id="clear_filter_i" href="/${orgi}/design/query/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>/clearFilter.html" data-toggle="load" data-target="#design_table"></i>
					<i style="display: none;" id="reset_filter_i" href="/${orgi}/design/query/${report.id!''}/<#if reportModel??>${reportModel.id!''}</#if>/resetFilter.html" data-toggle="load" data-target="#filterlist_div"></i>
				</div>
				<div class="btnWrap" style="margin-top:0px;">
					<input type="submit" style="margin-right:0px" class="subButtonStyle" value="查询"/>
				</div>
			</div>
		</td>
	</tr>
</table>
<input type="hidden" name="p" value="<#if reportData??>${reportData.page}</#if>">
<input type="hidden" name="ps" value="<#if reportData??>${reportData.pageSize}</#if>">
<script language="javascript">
//20140310 Bina
$(document).ready(function(){
	if(layoutIniting == false){
		initLayout();
	}
	layoutIniting = false ;
	//$(".shrinkage .sk_bt").addClass("active");
	$(".shrinkage table:not(:first)").hide();
 
	$(".shrinkage .sk_bt").click(function(){
		$(this).next("table")
		.slideToggle("fast",function(){
			//resizeDesign();
		})
		.siblings("table").slideUp("fast");
		$(this).toggleClass("active");
		$(this).siblings(".sk_bt").removeClass("active");
	});
	<#if ation_message??>
	alertMsg('${ation_message}');			
	</#if>		
	
});
function controlDiv(id){
	if($("#but"+id).hasClass("a_close")){
		$("#"+id).slideUp(50);
		$("#but"+id).attr("class","tbControlIcon a_open");
	}else{
		$("#"+id).slideDown(50);
		$("#but"+id).attr("class","tbControlIcon a_close");
	}
} 
</script>
